import { Toast } from 'vant';
import cTitle from "components/title";

export default {
  data() {
    return {
      data_info: {},
      id:'',
      //定位
      location: {},
    };
  },

  activated() {
    this.id = this.$route.params.id;
    // this.location = this.$store.state.o2oLocation;
    // this.id =  1162 ;
    // this.location = {
    //   city: "上海市",
    //   province: "上海市",
    //   point: {
    //     lat:'28.65119',
    //     lng:"115.887208"
    //   }
    // }
    // if (this.fun.isTextEmpty(this.location.point)) {
    // } else {
    //   this.getData();
    // }
    this.fun.getLocation()
      .then((res)=> {
        this.location = res;
        this.getData();
      })
      .catch((err)=> {
        console.log(err);
      });
  },
  created() {

  },
  mounted() {

  },
  methods: {
    getData() {
      let p = this.fun.bd_encrypt(this.location.point.lng, this.location.point.lat);
      let json = {
        lng: p.lng,
        lat: p.lat,
        hotel_id:this.id
      };
      $http
        .post("plugin.hotel-supply.frontend.home.get-hotel", json)
        .then(res => {
          if (res.result == 1) {
            this.data_info = res.data;
          }else{
            this.$dialog.alert({message:res.msg});

          }
        })
        .catch(error => {
          console.log(error);
        });
    },
    goToAdress(lng, lat) {
      let point = this.fun.bd_decrypt(
        // this.location.point.lng,
        // this.location.point.lat
        lng,
        lat
      );
      this.fun.goToWXAdress(point, this.data_info.hotel_name, "详细地址");
    },

    gotoGoods(id) {
      let hotel_id =this.id;
      this.$router.push(this.fun.getUrl('hotelSupplyGoods',{hotel_id:hotel_id,id:id}));
    },
  },
  components: { cTitle}
};
